package com.me {
	import com.me.components.BitImage;
	import com.me.components.MapResource;
	
	import flash.display.DisplayObject;
	
	import spark.core.SpriteVisualElement;

	/**
	 *
	 * @author yw
	 *
	 * @Date 2011-9-16 下午04:31:51
	 */
	public class SceneLayer extends SpriteVisualElement {
		public function SceneLayer() {
			super();
			this.mouseChildren = this.mouseEnabled = true;
		}

//		public function addBackgroud(bg:MapResource):void {
//			clear();
//			addChild(bg);
//		}
		override public function addChild(child:DisplayObject):DisplayObject {
			clear();
			return super.addChild(child);
		}

		public function backgroud():BitImage {
			if (numChildren > 0) {
				var d:DisplayObject = getChildAt(0);
				if (d is BitImage) {
					return d as BitImage;
				}
			}
			return null;
		}

		public function clear():void {
			while (numChildren > 0) {
				removeChildAt(0);
			}
		}
	}
}
